package org.crspta.gohomenotes.domain;

import java.util.Calendar;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.jpa.activerecord.RooJpaActiveRecord;
import org.springframework.roo.addon.tostring.RooToString;

@RooJavaBean
@RooToString
@RooJpaActiveRecord(finders = { "findPeopleByFirstNameEqualsAndLastName", "findPeopleByEmail" })
public class Person {

    @NotNull
    @Size(min = 1, max = 30)
    private String firstName;

    @NotNull
    @Size(min = 1, max = 30)
    private String lastName;

    @Size(min = 1, max = 30)
    private String nickname;

    @Size(min = 7, max = 30)
    private String homePhone;

    @Size(min = 7, max = 30)
    private String cellPhone;

    @Size(min = 7, max = 30)
    private String workPhone;

    private String email;

    @ManyToOne
    private Family family;

    @Temporal(TemporalType.TIMESTAMP)
    @DateTimeFormat(style = "M-")
    private Calendar birthDay;
    
    public String toString() {
    	return new StringBuilder().append(lastName).append(", ").append(firstName).toString();
    }
}
